﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace automata
{
    public partial class AutomataView : Form
    {
        AutomataModel m_Model;
        Form2 f2;
        Form3 f3;
        public AutomataView()
        {
            m_Model = new AutomataModel();
            InitializeComponent();
        }
        
        private void button1_Click(object sender, EventArgs e)
        {


                if (m_Model.login(textBox1.Text, textBox2.Text) == true)
                {
                    MessageBox.Show("Sikeres belépés");
                    f2 = new Form2(m_Model.get_Balance());
                    f2.Show();
                    f2.FormClosing += new FormClosingEventHandler(f2_FormClosing);
                }
                else
                {
                    MessageBox.Show("Hibás pin, vagy nem érvényesek a megadott adatok");
                }
           

        }

        void f2_FormClosing(object sender, FormClosingEventArgs e)
        {
            m_Model.take_Cash(f2.Get_balance());
        }



        private void button3_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            f3 = new Form3(f2.Get_balance());
            f3.Show();
        }
    }
}
